package com.esri.core.internal.tasks;

import com.esri.core.io.UserCredentials;
import com.esri.core.map.CallbackListener;

/* loaded from: classes.dex */
public class PollingHelper<T, U> {
    private static final int a = 600000;
    private PollingStatusCallback<T> b;
    private CallbackListener<?> c;

    /* loaded from: classes.dex */
    public interface PollingStatusCallback<T> {
        void statusUpdated(T t);
    }

    /* loaded from: classes.dex */
    public interface StatusCallback<T, U> {
        T determineFailedStatus(Exception exc);

        U getStatus(T t);

        T getStatusObject(String str, UserCredentials userCredentials) throws Exception;

        boolean isComplete(U u);
    }

    public void a(PollingStatusCallback<T> pollingStatusCallback, CallbackListener<?> callbackListener) {
        this.b = pollingStatusCallback;
        this.c = callbackListener;
    }

    /* JADX WARN: Code restructure failed: missing block: B:43:0x0094, code lost:
        if ((r19 - r17) < 600000) goto L37;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:17:0x0038  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x009a  */
    /* JADX WARN: Type inference failed for: r25v0, types: [com.esri.core.internal.tasks.PollingHelper<T, U>, com.esri.core.internal.tasks.PollingHelper] */
    /* JADX WARN: Type inference failed for: r31v0, types: [com.esri.core.internal.tasks.PollingHelper$StatusCallback<T, U>, com.esri.core.internal.tasks.PollingHelper$StatusCallback] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public T a(long r26, java.lang.String r28, com.esri.core.io.UserCredentials r29, U r30, com.esri.core.internal.tasks.PollingHelper.StatusCallback<T, U> r31) {
        /*
            r25 = this;
            r1 = r25
            r2 = r28
            r3 = r29
            r4 = r31
            long r5 = java.lang.System.currentTimeMillis()
            java.lang.System.currentTimeMillis()
            long r7 = java.lang.System.currentTimeMillis()
            java.lang.Object r9 = r4.getStatusObject(r2, r3)     // Catch: java.lang.Exception -> L23
            java.lang.Object r10 = r4.getStatus(r9)     // Catch: java.lang.Exception -> L21
            r1.a(r9)     // Catch: java.lang.Exception -> L1f
            goto L2a
        L1f:
            r0 = move-exception
            goto L27
        L21:
            r0 = move-exception
            goto L25
        L23:
            r0 = move-exception
            r9 = 0
        L25:
            r10 = r30
        L27:
            r0.printStackTrace()
        L2a:
            r12 = 0
            r14 = 1
            r15 = r9
            r11 = r10
            r17 = r12
            r16 = 1
            r9 = r5
            r5 = r26
        L36:
            if (r16 == 0) goto Laf
            boolean r0 = r4.isComplete(r11)
            if (r0 != 0) goto Lac
            java.lang.Thread r0 = java.lang.Thread.currentThread()
            boolean r0 = r0.isInterrupted()
            if (r0 == 0) goto L49
            goto Lac
        L49:
            long r19 = java.lang.System.currentTimeMillis()
            long r21 = r19 - r7
            r23 = 300000(0x493e0, double:1.482197E-318)
            int r0 = (r21 > r23 ? 1 : (r21 == r23 ? 0 : -1))
            if (r0 <= 0) goto L5a
            r5 = 60000(0xea60, double:2.9644E-319)
            goto L6c
        L5a:
            r23 = 120000(0x1d4c0, double:5.9288E-319)
            int r0 = (r21 > r23 ? 1 : (r21 == r23 ? 0 : -1))
            if (r0 <= 0) goto L64
            r5 = 30000(0x7530, double:1.4822E-319)
            goto L6c
        L64:
            r23 = 15000(0x3a98, double:7.411E-320)
            int r0 = (r21 > r23 ? 1 : (r21 == r23 ? 0 : -1))
            if (r0 <= 0) goto L6c
            r5 = 5000(0x1388, double:2.4703E-320)
        L6c:
            long r21 = r19 - r9
            int r0 = (r21 > r5 ? 1 : (r21 == r5 ? 0 : -1))
            if (r0 < 0) goto L36
            java.lang.Object r15 = r4.getStatusObject(r2, r3)     // Catch: java.lang.Exception -> L80
            java.lang.Object r11 = r4.getStatus(r15)     // Catch: java.lang.Exception -> L80
            r1.a(r15)     // Catch: java.lang.Exception -> L80
            r17 = r12
            goto La7
        L80:
            r0 = move-exception
            boolean r9 = r0 instanceof com.esri.core.io.EsriServiceException
            if (r9 == 0) goto L97
            int r9 = (r17 > r12 ? 1 : (r17 == r12 ? 0 : -1))
            if (r9 != 0) goto L8d
            r17 = r19
        L8b:
            r9 = 1
            goto L98
        L8d:
            long r19 = r19 - r17
            r9 = 600000(0x927c0, double:2.964394E-318)
            int r21 = (r19 > r9 ? 1 : (r19 == r9 ? 0 : -1))
            if (r21 >= 0) goto L97
            goto L8b
        L97:
            r9 = 0
        L98:
            if (r9 != 0) goto La7
            java.lang.Object r15 = r4.determineFailedStatus(r0)
            com.esri.core.map.CallbackListener<?> r9 = r1.c
            if (r9 == 0) goto La5
            r9.onError(r0)
        La5:
            r16 = 0
        La7:
            long r9 = java.lang.System.currentTimeMillis()
            goto L36
        Lac:
            r16 = 0
            goto L36
        Laf:
            return r15
        */
        throw new UnsupportedOperationException("Method not decompiled: com.esri.core.internal.tasks.PollingHelper.a(long, java.lang.String, com.esri.core.io.UserCredentials, java.lang.Object, com.esri.core.internal.tasks.PollingHelper$StatusCallback):java.lang.Object");
    }

    void a(T t) {
        PollingStatusCallback<T> pollingStatusCallback = this.b;
        if (pollingStatusCallback != null) {
            pollingStatusCallback.statusUpdated(t);
        }
    }
}
